

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int f(int x) {
  int sum = 0;
  while (x != 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
};
int main() {
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);


  /* auto f = [](int x) {
    int sum = 0;
    while (x != 0) {
      sum += x % 10;
      x /= 10;
    }
    return sum;
  }; */
  int n;
  cin >> n;
  int res = 1;
  for (int i = 1; i < n; i++) {
    res = res + f(res);
  }
  cout << res << '\n';
}